<%@page import="java.util.List"%>
<%@page import="cn.zongtilei.BanjiServlet"%>
<%@page import="cn.lei.PageBean2"%>
<%@page import="cn.lei.Banji"%>
<%@page import="org.apache.jasper.tagplugins.jstl.core.ForEach"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
		<link rel="stylesheet" type="text/css" href="lib/bootstrap/css/bootstrap.css" />
		<!--引入jquery-->
		<script type="text/javascript" src="lib/jquery-1.11.1.js" ></script>
		<!--引入js-->
		<script type="text/javascript" src="lib/bootstrap/js/bootstrap.js" ></script>
		<script type="text/javascript" src="../../jquery-1.11.1.js"></script>
		<script type="text/javascript">
		function selectAll(){
			//得到上面全选、反选按钮的状态
			var isChecked = $("#selectAlls").prop("checked");
			//下面所有checkbox状态和上面全选/反选checkbox的状态一致
			$("input[name=selectIds]").prop("checked",isChecked);
			}
		function deleteById(id) {
			//用户点了确定，confirm返回的就是true
			//用户点了取消，confirm返回的就是false
			var isDel = confirm("您确认要删除吗?");	//相当于弹框
			if(isDel){
				location.href = "/Java1807Web/banji?method=deleteById&id="+id;
			}
		}
		
		</script>
</head>
<body>
<%
		PageBean2 pageBean2 = (PageBean2)request.getAttribute("pageBean2");
%>
<a href="banji_add.jsp">增加</a>
	<table class="table table-striped table-bordered table-hover table-condensed">
		<tr>
			<td>全选/全不选<input type="checkbox" id="selectAlls" onclick="selectAll()" /></td>
			<td>id</td>
			<td>name</td>
			<td>number</td>
			<td>删除</td>
			<td>修改</td>
		</tr>
			<%
			for(Banji banji:pageBean2.getList()){
			%>
		 <tr>
			<td><input type="checkbox" name = "selectIds" value=<%=banji.getId() %>/></td>
			<td><%=banji.getId() %></td>
			<td><%=banji.getName() %></td>
			<td><%=banji.getNumber()%></td>
			<td><a href="javascript:deleteById(<%=banji.getId()%>)">删除</a></td>
			<td><a href="<%=request.getContextPath() %>/banji?method=toupdate&id=<%=banji.getId()%>">修改</a></td>
		</tr>
			<%
			}
			%>
		
		
		 
	</table>
	<nav aria-label="Page navigation">
		 <ul class="pagination">
		 <li>
		 <%if(pageBean2.getPageNo()>1){
			 
			 %>
			  <a href="<%=request.getContextPath()%>/banji?method=pageList&pageNo=<%=pageBean2.getPageNo()-1%>&pageSize=3" aria-label="Previous">
		<% } else{
		}%>
		 
		    
		     
		        <span aria-hidden="true">&laquo;</span>
		      </a>
		    </li>
		    <%
		    	for(int i = 1;i<= pageBean2.getTotalPage();i++){
		    		if(i==pageBean2.getPageNo()){
		    			%>
		    		
		    		 	 <li class="active"><a href="#"><%=i %></a></li>
		    		<%}else{%>
		    		
		    		 <li><a href="<%=request.getContextPath()%>/banji?method=pageList&pageNo=<%=i%>&pageSize=3"><%=i %></a></li>
		    	<%	}
		    
		   
		  
		    	 }%>
		    <li>
		    <%
		    if(pageBean2.getPageNo()<pageBean2.getTotalPage()){
		    	
		   
		    %>
		      <a href="<%=request.getContextPath()%>/banji?method=pageList&pageNo=<%=pageBean2.getPageNo()+1%>&pageSize=3" aria-label="Next">
		      <% }else{} %>
		        <span aria-hidden="true">&raquo;</span>
		      </a>
		    </li>
		  </ul>
		</nav>


</body>
</html>